package com.sb.model;


import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;


public class User implements UserDetails {

	private static final long serialVersionUID = 1L;
	
	private Integer id;

	private String username;

	private String password;

	private Boolean accountNonExpired;

	private Boolean accountNonLocked;

	private Boolean enabled;

	private Set<Role> roles;
	
	
	public User(Integer id, String username, String password,
			Boolean accountNonExpired, Boolean accountNonLocked,
			Boolean enabled, Set<Role> roles) {
		super();
		this.id = id;
		this.username = username;
		this.password = password;
		this.accountNonExpired = accountNonExpired;
		this.accountNonLocked = accountNonLocked;
		this.enabled = enabled;
		this.roles = roles;
	}

	public Collection<GrantedAuthority> getAuthorities() {
		List<GrantedAuthority> list = new ArrayList<GrantedAuthority>();
		list.addAll(roles);
		return list;
	}
	
	public Integer getId() {
		return id;
	}
	
	public String getPassword() {
		return this.password;
	}

	public String getUsername() {

		return this.username;
	}

	public boolean isAccountNonExpired() {
		return this.accountNonExpired;
	}

	public boolean isAccountNonLocked() {
		return accountNonLocked;
	}

	public boolean isCredentialsNonExpired() {
		return true;
	}

	public boolean isEnabled() {
		return enabled;
	}
	
	public Set<Role> getRoles() {
		return roles;
	}
	
	
}
